﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MyLibary.DAL;

namespace MyLibary.BIZ
{
   public  class BIZ_SanPham
    {
#region Field
      public string MaSanPham { get; set; }
      public string TenSanPham { get; set; }
       public string MoTa { get; set; }
       public string LinkAnh{get;set;}
       public decimal GiaBan{get;set;}
       public decimal GiaNhap { get; set; }
       public string MaLoai{get;set;}

       BIZ_LoaiSanPham LoaiSanPham
       {
           get{return DAL.DAL_LoaiSanPham .GetLoaiSanPham(this.MaLoai);}
       }
       #endregion
#region Methold
       public BIZ_SanPham(){}
       public BIZ_SanPham(string MaSanPham,string TenSanPham,decimal GiaNhap,decimal GiaBan,string MoTa,string LinkAnh,string MaLoai)
       {
           this.MaSanPham=MaSanPham;
           this.TenSanPham=TenSanPham;
           this.GiaNhap = GiaNhap;
           this.GiaBan = GiaBan;
           this.MoTa=MoTa;
           this.LinkAnh=LinkAnh;
           this.MaLoai=MaLoai;
       }
       public static List<BIZ_SanPham>getAll()
       {
           return DAL_SanPham.GetAll();
       }
       public static BIZ_SanPham getByID(string MaSanPham)
       {
           return DAL_SanPham.GetById(MaSanPham);
       }
       public bool Add()
       {
           return DAL_SanPham.Insert(this);
       }
       public bool Update()
       {
           return DAL_SanPham.Update(this);
       }
       public bool Delete()
       {
           return DAL_SanPham.Delete(this);
       }
#endregion
    }
class IEQualityCompareSanPham:IEqualityComparer<BIZ_SanPham>
{
#region :IEqualityComparer<BIZ_SanPham>
    public bool Equals(BIZ_SanPham x,BIZ_SanPham y){return x.MaSanPham==y.MaSanPham;}
    public int GetHashCode(BIZ_SanPham Object){return Object.GetHashCode();}
#endregion
}
}
